import base64
import json
import time


base64_data = 'MqECAApkZXZfdXAva3doAAR7Im1lc3NhZ2VpZCI6IiIsIm1ldGVybnVtIjoiOTkyMjA4MjMwOTM2Iiwic2lnbmFsbGV2ZWwiOjMxLCJkYXRhdHlwZSI6MiwiZnJvemVuIjoxLCJ0aW1lIjoxNjY3MTQ1NjAwLCJsb29wIjoxLCJmb3J3YXJka3doIjoiNTQuNzIkMjUuNDMkNS4xOSQyMC44NSQzLjI2IiwicmV2ZXJzZWt3aCI6IjkuOTMkOS4zNyQwLjAwJDAuNDgkMC4wOCIsImZvcndhcmRrdmFyIjoiNy4yMiQzLjQ5JDAuMDMkMy41NSQwLjE2IiwicmV2ZXJzZWt2YXIiOiI0LjkwJDIuMDQkMC4wMCQyLjc3JDAuMDgifQ=='
hex_data = base64.b64decode(base64_data) 
print ('all_hex_data=', hex_data)

zero1_pos = hex_data.find(b"\x00")
print('zero1_pos=', zero1_pos)
#hex_data = hex_data[zero1_pos+2:]
zero2_pos = hex_data.find(b"\x00", zero1_pos+2)
print('zero2_pos=', zero2_pos)
str_data = hex_data[zero1_pos+2 : zero2_pos]
print('str_data=', str_data)
json_data = hex_data[zero2_pos+2 :]
print('json_data=', json_data)

print(json.loads(json_data))

localtime = time.localtime(time.time())#获取当前时间
time_str = time.strftime('%Y-%m-%d_%H-%M-%S',time.localtime(time.time()))#把获取的时间转换成"年月日格式”
print(time_str) 
file = open('out_'+time_str+'.json', "wb+")
file.write(json_data)
#file.write(json_data.to_json(orient='records'))
file.flush()
file.close